package com.espirit.eap.util.tagAdaptor;

import java.util.Map;

import com.espirit.eap.pagelayout.Element;
import com.espirit.eap.pagelayout.Layout;
import com.espirit.eap.pagelayout.PageCache;
import com.espirit.eap.pagelayout.TagInfo;

public interface TagElementAdaptor<T extends Element> {
	// The only one special code: it output the tag property to tag body directly
	final static String TAG_CODE = "code";
	// A flag to tell the 'Conversion'
	final static String TAG_CODE_ANONYMOUS = "anonymous";
	
	final static String TAG_TEMPLATE = "template";
	// the tag information of template
	final static String TAG_TEMPLATE_TAGINFO = "tagInfo";
	// boolean flag to identify if the template file contains the tag information
	final static String TAG_TEMPLATE_CONTAIN = "templateContainTagInfo";
	
	// properties variable
	final static String ELEMENT_OLD_PARENT = "elementOldParent";
	static final String ELEMENT_PARENT = "elementParent";
	final static String DEFAULT_TAG_PROP = "defaultTagProp";
	final static String POSITION_ROW = "positionRow";
	final static String POSITION_COL = "positionCol";
	final static String NAME = "name";
	
	// context for getTagProperties
	final static String FORM_ID = "formId";
	final static String INVOKER = "invoker";
	
	TagInfo getTagProperties(Layout root, T element, Map<String, Object> context);
	
	String getTagName(T element);
	
	/**
	 * Update tagProperties to existed element
	 * 
	 * @param tagProperties
	 * @param existed
	 * @param context
	 * @param pageCache
	 * @return
	 */
	T updateToElement(Map<String, String> tagProperties, T existed, Map<String, Object> context, PageCache pageCache);
	
	/**
	 * Delete existed element
	 * 
	 * @param parent
	 * @param existed
	 * @param pageCache
	 */
	void deleteElement(Element parent, T existed, PageCache pageCache);
	
	/**
	 * Add tag & properties to parent element
	 * 
	 * @param parent
	 * @param tagName
	 * @param properties
	 * @param pageCache
	 * @return
	 */
	// parent can be BlockSection or Layout
	Element addElement(Element parent, String tagName, Map<String, Object> properties, PageCache pageCache);
}
